#region Usings
using System.Collections.Generic;
using System.Linq;
using BK.Model;
using BK.Repositories.Abstract;
#endregion

namespace BK.Repositories.EF
{
	public class CurrenciesRepository : BaseRepository<Currency>, ICurrenciesRepository
	{
		#region ICurrenciesRepository Members
	    public CurrenciesRepository(BkDataContext dataContext) : base(dataContext)
	    {
	    }

	    public Currency GetBy(int userId, string currencyName)
		{
			Currency result = (from currency in ObjectSet
			                   where (currency.UserId == userId) && (currency.ShortName == currencyName)
			                   select currency).FirstOrDefault();
			return result;
		}

	    public IEnumerable<Currency> GetByUserId(int userId)
	    {
	        Currency[] result = (from currency in ObjectSet
	                             where (currency.UserId == userId)
	                             select currency).ToArray();
	        return result;
	    }
	    #endregion
	}
}